/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package controller;

import java.rmi.*;
import java.rmi.registry.*;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import model.DatabaseConnection;
import view.ControlPanel;


/**
 *
 * @author mona
 */
public class ServerApp {
    public static void main(String[] args)
    { new ServerApp(); }
    
    public ServerApp(){
        try{
            ChatServerImpl obj = new ChatServerImpl(); 
            Registry reg = LocateRegistry.createRegistry(5010);
            reg.rebind("HelloService", obj);
            System.out.println("Bind Successfully ...");
            view.ControlPanel cp =new ControlPanel(obj,reg);
            obj.setControlPanel(cp);
            cp.setVisible(true);
            
            
        }catch(RemoteException ex){  
            System.out.println("Error .. Server already running"); 
        } 
    }
        
}
